package com.codingfuture.service.impl;

import com.codingfuture.entity.User;
import com.codingfuture.mapper.UserMapper;
import com.codingfuture.service.UserService;
import com.codingfuture.util.Md5Utils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public boolean login(User user) {
        String password = Md5Utils.md5(user.getPassword());
        User u = userMapper.findByUsername(user.getUsername());
        if (u != null && u.getPassword().equals(password)) {
            // 登陆成功
            return true;
        }
        // 登录失败
        return false;
    }
}
